const express = require('express');
const router = express.Router();
const adminController = require('../controllers/adminController');
const carouselController = require('../controllers/carouselController');
const hotRecommendController = require('../controllers/hotRecommendController');
const { authMiddleware, superAdminOnly } = require('../middleware/authMiddleware');

// 登录相关接口
router.post('/login', adminController.login);
router.post('/send-code', adminController.sendVerificationCode);

// 管理员信息接口
router.get('/info', authMiddleware, adminController.getAdminInfo);
router.post('/logout', authMiddleware, adminController.logout);

// 轮播图管理接口
router.get('/carousels', authMiddleware, carouselController.getCarouselList);
router.get('/carousels/:id', authMiddleware, carouselController.getCarouselDetail);
router.post('/carousels', authMiddleware, superAdminOnly, carouselController.createCarousel);
router.put('/carousels/:id', authMiddleware, superAdminOnly, carouselController.updateCarousel);
router.delete('/carousels/:id', authMiddleware, superAdminOnly, carouselController.deleteCarousel);
router.put('/carousels/:id/status', authMiddleware, superAdminOnly, carouselController.updateCarouselStatus);
router.post('/carousels/reorder', authMiddleware, superAdminOnly, carouselController.updateCarouselOrder);

// 热点推荐管理接口
router.get('/hot-recommends', authMiddleware, hotRecommendController.getHotRecommendsAdmin);
router.post('/hot-recommends', authMiddleware, superAdminOnly, hotRecommendController.addHotRecommend);
router.put('/hot-recommends/:id', authMiddleware, superAdminOnly, hotRecommendController.updateHotRecommend);
router.delete('/hot-recommends/:id', authMiddleware, superAdminOnly, hotRecommendController.deleteHotRecommend);

// 店铺管理接口
router.get('/stores', authMiddleware, superAdminOnly, adminController.getStoresList);
router.get('/stores/:id', authMiddleware, superAdminOnly, adminController.getStoreDetail);
router.put('/stores/:id/audit', authMiddleware, superAdminOnly, adminController.auditStore);

// 商家申请管理接口
router.get('/merchant-applications', authMiddleware, superAdminOnly, adminController.getStoresList);
router.get('/merchant-applications/:id', authMiddleware, superAdminOnly, adminController.getStoreDetail);
router.put('/merchant-applications/:id/audit', authMiddleware, superAdminOnly, adminController.auditStore);

// 优惠券管理接口
router.get('/coupons', authMiddleware, adminController.getCouponsList);
router.post('/coupons', authMiddleware, superAdminOnly, adminController.createCoupon);
router.put('/coupons/:id/status', authMiddleware, superAdminOnly, adminController.updateCouponStatus);

// 数据统计接口
router.get('/statistics', authMiddleware, adminController.getStatistics);

module.exports = router;